<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Mali OpenCL SDK v1.1.0: Image Objects</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Mali OpenCL SDK v1.1.0
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li class="current"><a href="pages.html"><span>Help&#160;and&#160;Tutorials</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('image_objects_tutorial.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Image Objects </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>An overview of OpenCL image objects including sample code.</p>
<h1><a class="anchor" id="imageObjectsIntroduction"></a>
Introduction</h1>
<p>Textures (images) are a huge part of modern graphics applications. As such, graphics hardware has developed to allow high perfomance access and operations on textures.</p>
<p>To make use of this specialised hardware, OpenCL includes an optional image data type. These 'images objects' are supported on all Mali-T600 series GPUs.</p>
<p>Images represent large grids of data which can be processed in parallel. As such, image data and image operations are usually a good fit for accelerating in OpenCL.</p>
<p>Images data can be stored/manipulated by OpenCL in two ways; buffers and images.</p>
<h2><a class="anchor" id="imageObjectsBuffers"></a>
Memory Buffers</h2>
<p>Memory buffers are just plain arrays of data.</p>
<p>Because they are suitable for all forms of data (e.g. images, grids, linear arrays, etc.), various image operations are difficult:</p>
<ul>
<li>To access image data at given coordinates, you must calculate the correct offset into the data.</li>
<li>You must use exact coordinates to access you data, or implement you own access methods for normalised (or other) coordinates.</li>
<li>You must also handle the case where the coordinates are outside of the image area.</li>
<li>Any algorithms or optimisations are usually fixed to the image format being used e.g. RGB888 (if you then change the image format, the algorithm/optimisations must be changed).</li>
<li>Image filtering (e.g. bilinear filtering) must be done manually.</li>
</ul>
<h2><a class="anchor" id="imageObjectsImageObjects"></a>
Image Objects</h2>
<p>Image objects are a specialist memory type which makes it easier to work with image data. Image objects:</p>
<ul>
<li>support access by coordinates directly</li>
<li>support normalized coordinates</li>
<li>handle out-of-range coordinates (you can choose from various handling schemes)</li>
<li>provide an abstract image format (accessing RGB888 images is the same as accessing RGB565 images)</li>
<li>support bilinear filtering (accelerated by hardware)</li>
</ul>
<h1><a class="anchor" id="imageObjectsRecommendations"></a>
Recommendations</h1>
<p>Whether to use image objects or not depends on the application. You should take the following considerations into account:</p>
<ul>
<li>Using image objects for image data simplifies the code needed to access and manipulate the data (see <a class="el" href="image_objects_tutorial.html#imageObjectsImageObjects">Image Objects</a>).</li>
<li><p class="startli">When using image objects, only 1 pixel can be processed per cycle. Using buffers, if your image format is less than 32-bits per channel you can process multiple pixels per cycle.</p>
<p class="startli">For example, if the image format is RGBA8888 (each pixel is 32-bits), using buffers, you can vectorize the algorithm to operate on 4 pixels at once (32-bits * 4 pixels = 128-bits, the recommended vector width for Mali-T600 series GPUs.) But with image objects the speed is fixed at one pixel per cycle.</p>
<p class="startli">If the format is 32-bits per channel or greater, this advantage of image objects is lost because only one pixel can be processed per cycle using either method. For example, if the image format is RGBA32 (each pixel is 128-bits), only 1 pixel can be processed per cycle because 1 pixel fills the recommended vector width.</p>
<p class="startli">For more information about vectorization, see <a class="el" href="hello_world_vector_tutorial.html">Vectorizing your OpenCL code</a>.</p>
</li>
<li><p class="startli">In more complex cases, maximum performance comes from balancing load across the system. On Mali-T600 series GPUS, image objects use the Texture pipeline which is seperate from the Load/Store and Arithmetic pipelines. As such, it might be beneficial to use both image objects and buffers in order to make maximum use of the system.</p>
<p class="startli">For example, loading input images with image objects and then loading the data to alter the images in memory buffers (e.g. a convolution filter).</p>
</li>
</ul>
<h1><a class="anchor" id="imageObjectsSample"></a>
Sample Code</h1>
<ul>
<li><p class="startli"><a class="el" href="image_scaling_tutorial.html">Image Scaling</a></p>
<p class="startli">How to resize an image using OpenCL image objects.  </p>
</li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="tutorials.html">Tutorials</a></li>
    <li class="footer">
        <a href="http://www.arm.com/">(C) ARM Ltd. 2013</a>
    </li>
  </ul>
</div>
</body>
</html>
